package com.task.web.controller.core;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.task.common.core.controller.BaseController;
import com.task.common.core.domain.AjaxResult;
import com.task.core.dto.request.DataFileUploadRequestDTO;
import com.task.core.dto.request.SysFileRequestDTO;
import com.task.core.service.DataFileOperationService;

import io.swagger.annotations.Api;

/**
 * @author 迪迦.
 * @date 2024/11/13 13:56
 */
@Api("")
@RestController
@RequestMapping("/dataFileOperation")
public class DataFileOperationController extends BaseController {

  @Resource
  private DataFileOperationService dataFileOperationService;

  @RequestMapping("/importFile")
  public AjaxResult dataFileUpload(DataFileUploadRequestDTO request)
      throws IOException, URISyntaxException {
    return success(dataFileOperationService.dataFileUpload(request));
  }

  @PostMapping("/clearSuccessRecord")
  public AjaxResult clearSuccessRecord(@RequestBody List<String> fileCodes) {
    dataFileOperationService.clearSuccessRecord(fileCodes);
    return success();
  }
  //
  //@GetMapping("/getDataImportProgress/{fileCode}")
  //public AjaxResult getDataImportProgress(@PathVariable("fileCode") String fileCode) {
  //  return success(dataFileOperationService.getDataImportProgress(fileCode));
  //}

  @GetMapping("/getDataImportProgress")
  public AjaxResult getDataImportProgress() {
    return success(dataFileOperationService.getDataImportProgress());
  }

  @PutMapping("/stopImport/{fileCode}")
  public AjaxResult stopImport(@PathVariable("fileCode") String fileCode) {
    dataFileOperationService.stopImport(fileCode);
    return success();
  }

  //@GetMapping("/copyTaskData/{tableName}")
  //public void copyTaskData(@PathVariable String tableName) {
  //  dataFileOperationService.copyTaskData(tableName);
  //}

}
